<?php
if (!isset($_SESSION)) session_start();
//print_r($_POST);
$e = isset($_POST["email"])?$_POST["email"]:"";
$p = isset($_POST["password"])?$_POST["password"]:"";
	function ktraUser($e,$p)
	{
	include "connect.php";
	$p=md5($p);
	$sql ="select * from khachhang where email='$e' && matkhau='$p' ";
	$kq = mysql_query($sql);
	if (!$kq) return false;
	$n =mysql_num_rows($kq);
	//i$n= mysql_fetch_assoc($kq);
	if($n>0)
	 	return true;
	else return false;
	}
	//if (isset($e) && isset($p))
	if (ktraUser($e,$p)==true)
	{
	$_SESSION["dadangnhap"]=1;
	$_SESSION["e"] = $e;
	
	header("location:index.php");
	//echo " dang nhap thanh cong";
	exit;
	}
	else{
	//echo "OKOK";
	echo "ma dang nhap sai";
	exit;	
	}


